package com.trkj.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.trkj.dao.HouseholdDao;
import com.trkj.entity.HouseholdEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
@Slf4j
@Service
public class HouseholdImpl implements HouseholdService{
    @Autowired
    private HouseholdDao householdDao;
    @Override
    @Cacheable(cacheNames = "allusers",key = "#currentPage+','+#pageSize")
    public PageInfo<HouseholdEntity> findAllHousehold(HouseholdEntity householdEntity , int currentPage, int pageSize){
        PageHelper.startPage(currentPage,pageSize);
        List<HouseholdEntity> List= this.householdDao.findAllHousehold(householdEntity);
        PageInfo<HouseholdEntity> pageDto=new PageInfo<>(List);
        log.debug("123:{}",pageDto);
        return pageDto;
    }

    @Override
    public Boolean addHousehold(HouseholdEntity householdEntity) {
        return householdDao.addHousehold(householdEntity);
    }

    @Override
    public Boolean updateHold(HouseholdEntity householdEntity) {
        return householdDao.updateHold(householdEntity);
    }

    @Override
    public Boolean delHold(int id) {
        return householdDao.delHold(id);
    }

    @Override
    public List<HouseholdEntity> findBiaoQian() {
        return householdDao.findBiaoQian();
    }

    //查询所有住户数量
    @Override
    public List<HouseholdEntity> ZhuHuList(){
        return householdDao.ZhuHuList();
    }
}
